<?php defined('SYSPATH') or die();?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
<title>配置首页</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('style.css,base.css,base2.css,base_new.css'); }
    {php echo Common::getScript("uploadify/jquery.uploadify.min.js,product_add.js,choose.js,imageup.js"); }
    {php echo Common::getCss('uploadify.css','js/uploadify/'); }
    {Common::getScript('jquery.upload.js')}
</head>

<body>
	<table class="content-tab">
    <tr>
    <td width="119px" class="content-lt-td"  valign="top">
     {template 'stourtravel/public/leftnav'}
    <!--右侧内容区-->
    </td>
     <td valign="top" class="content-rt-td ">

          <form method="post"  id="frm" name="frm" enctype="multipart/form-data">
          <div class="manage-nr">
          	<div class="cfg-header-bar">
          		<a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" onclick="window.location.reload()">刷新</a>
          	</div>
            
            <!--基础信息开始-->
            <div class="product-add-div">
                <ul class="info-item-block">
                  	<li>
                  		<span class="item-hd">会员提现方式{Common::get_help_icon('cfg_member_withdraw_way')}：</span>
                  		<div class="item-bd">
                  			<label class="check-label mr-20"><input type="checkbox" name="cfg_member_withdraw_way[]" value="bank" {if in_array('bank',$cfg_member_withdraw_way)}checked="checked"{/if}/>银行卡</label>
                  			<label class="check-label mr-20"><input type="checkbox" name="cfg_member_withdraw_way[]" value="alipay" {if in_array('alipay',$cfg_member_withdraw_way)}checked="checked"{/if}/>支付宝</label>
                  			<label class="check-label mr-20"><input type="checkbox" name="cfg_member_withdraw_way[]" value="weixin" {if in_array('weixin',$cfg_member_withdraw_way)}checked="checked"{/if}/>微信</label>
                  		</div>	
                  	</li>
                    <li>
                        <span class="item-hd">每次提现金额：</span>
                        <div class="item-bd">
                            <label class="radio-label mr-30">
                                <input name="cash_min" type="radio" class="checkbox" {if $configinfo['cash_min']=='0'}checked{/if} value="0">无要求
                            </label>

                            <label class="radio-label mr-30">
                                <input name="cash_min" type="radio" class="checkbox" {if $configinfo['cash_min']=='1'}checked{/if} value="1">每次须达到
                                <input type="text" class="input-text w80 reset-input" name="cash_min_num" value="{$configinfo['cash_min_num']}" >以上才可提现
                            </label>
                        </div>
                    </li>

                    <li>
                        <span class="item-hd">每月提现次数：</span>
                        <div class="item-bd">
                            <label class="radio-label mr-30">
                                <input name="cash_max" type="radio" class="checkbox" {if $configinfo['cash_max']=='0'}checked{/if} value="0">无要求
                            </label>
                            <label class="radio-label mr-30">
                                <input name="cash_max" type="radio" class="checkbox" {if $configinfo['cash_max']=='1'}checked{/if} value="1">每月最多可提现
                                <input type="text" class="input-text w80 reset-input" name="cash_max_num" value="{$configinfo['cash_max_num']}">次
                            </label>
                        </div>
                    </li>
                    <li>
                        <div class="item-bd">
                           <span style="color: red"> 注意：2022.5月后开通的微信商户只能使用‘商家转账到零钱’，老用户依旧可以使用‘企业打款’，以下配置只针对‘商家转账到零钱’</span>
                        </div>
                    </li>
                    <li>
                        <span class="item-hd">打款接口：</span>
                        <div class="item-bd">
                            <label class="radio-label mr-30">
                                <input name="cfg_wxtx_api" type="radio" class="checkbox" {if $configinfo['cfg_wxtx_api']=='0'}checked{/if} value="0">企业打款接口
                            </label>
                            <label class="radio-label mr-30">
                                <input name="cfg_wxtx_api" type="radio" class="checkbox" {if $configinfo['cfg_wxtx_api']=='1'}checked{/if} value="1">商家转账到零钱接口
                            </label>
                        </div>
                    </li>
                    <li class="cfg_wxtx_api">
                        <span class="item-hd">微信商户号{Common::get_help_icon('payset_weixin_mchid')}：</span>
                        <div class="item-bd">
                            <input name="cfg_wxpay_mchid" type="text" value="{$configinfo['cfg_wxpay_mchid']}" id="cfg_wxpay_mchid" class="input-text w300">
                        </div>
                    </li>
                    <li class="cfg_wxtx_api">
                        <span class="item-hd">apiv3key{Common::get_help_icon('apiv3key')}：</span>
                        <div class="item-bd">
                            <input type="text" name="cfg_apiv3key" data-required="true" class="input-text w300" value="{$configinfo['cfg_apiv3key']}"/>
                        </div>
                    </li>

                    <li class="cfg_wxtx_api">
                        <span class="item-hd">证书序列号{Common::get_help_icon('apiv3key')}：</span>
                        <div class="item-bd">
                            <input type="text" name="cfg_merchantCertificateSerial" data-required="true" class="input-text w300" value="{$configinfo['cfg_merchantCertificateSerial']}"/>
                        </div>
                    </li>

                    <li class="cfg_wxtx_api">
                        <span class="item-hd">微信商户api证书{Common::get_help_icon('apiv3key')}</span>
                        <div class="item-bd">
                            <a href="javascript:;" id="upload_btn" class="btn btn-primary radius size-S">上传证书</a>
                            {if $configinfo['cfg_tx_api_cert']}
                            <span class="c-green isloaded ">*&nbsp;证书已上传！</span>
                            {/if}
                        </div>
                    </li>

                    <li class="cfg_wxtx_api">
                        <span class="item-hd">微信平台证书{Common::get_help_icon('cfg_platform_cert')}</span>
                        <div class="item-bd">
                            <a href="javascript:;" id="platformCert" class="btn btn-primary radius size-S">上传证书</a>
                            {if $configinfo['cfg_platform_cert']}
                            <span class="c-green isloaded ">*&nbsp;证书已上传！</span>
                            {/if}
                        </div>
                    </li>

                </ul>

            </div>
            <!--/基础信息结束-->
			
			<div class="clear clearfix pt-20">
                <a class="btn btn-primary radius size-L ml-115" href="javascript:;" id="btn_save">保存</a>
            </div>	
            
          </div>
        </form>
    </td>
   </tr>
</table>
<script>
	$(document).ready(function(){

        if($("input[name='cfg_wxtx_api']:checked").val()==1){
            $('.cfg_wxtx_api').show()
        }else {
            $('.cfg_wxtx_api').hide()
        }
        $("input[name='cfg_wxtx_api']").bind('input propertychange',function(e){
            if($(this).val()==1){
                $('.cfg_wxtx_api').show()
            }else {
                $('.cfg_wxtx_api').hide()
            }
        })

        $("#nav").find('span').click(function(){

            Product.changeTab(this,'.product-add-div');//导航切换
        })
        $("#nav").find('span').first().trigger('click');

        //上传文件
        $('#upload_btn').click(function(){
            uploadFile('finance/admin/finance/member/config/ajax_upload_api_cert');
        })

        //上传证书
        $('#platformCert').click(function(){
            uploadFile('finance/admin/finance/member/config/ajax_platformCert');
        })

        $("#btn_save").click(function(){
             $.ajaxform({
                     url:SITEURL+'{$prefix_url}/config/ajax_config_save',
                     form:'#frm',
                     dataType:'json',
                     method:'post',
                     success:function(result){
                         if(result.status)
                             ST.Util.showMsg('保存成功',4);
                         else
                             ST.Util.showMsg('失败',5)
                     }
                 })
        })

    });

    function uploadFile(url) {
        // 上传方法
        $.upload({
            // 上传地址
            url: SITEURL+url,
            // 文件域名字
            fileName: 'Filedata',
            fileType: 'pem',
            // 上传完成后, 返回json, text
            dataType: 'json',
            // 上传之前回调,return true表示可继续上传
            onSend: function() {
                return true;
            },
            // 上传之后回调
            onComplate: function(data) {
                if(data.status){
                    ST.Util.showMsg('证书上传成功',4);
                    location.reload();
                }else{
                    ST.Util.showMsg(data.msg,5);
                }
            }
        });

    }




</script>
</body>
</html>
